var webpack = require('webpack');
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    context: path.join(__dirname),
    entry:{
        // app:['webpack-hot-middleware/client?noInfo=true&reload=true',path.resolve(__dirname, "./src/index.js")]
        app: path.resolve(__dirname, "./src/index.js"),
        login:path.resolve(__dirname,"./src/login.js")   //可配置多个文件.
    },
    output:{
        path: path.resolve(__dirname,"./out/static"),  //  打包存放地址.
        publicPath:'/',  // 调试或者 CDN 之类的域名
        filename: "[name].js"  //  [name] 的值是entry的键值.[hash].
    },
    resolve:{
    },
    module: {
        loaders: [
            {
                test: /\.js?$/,
                exclude: /(node_modules)/,
                loader: 'babel-loader',
                query: {
                    presets: ['react', 'es2015']
                }
            }
        ]
    },
    plugins:[
        new HtmlWebpackPlugin({
            filename:'./index.html',
            // 渲染输出html文件名,路径相对于 output.path 的值.
            template:path.resolve(__dirname,'./src/views/index.html'),
            inject:true  // 渲染源模板文件
        }),
        new HtmlWebpackPlugin({
            template:path.resolve(__dirname,'./src/views/login.html'),
            filename:'./login.html',
            inject:true
        }),
        new webpack.optimize.OccurrenceOrderPlugin(),
        new webpack.HotModuleReplacementPlugin(),
        new webpack.NoErrorsPlugin()
    ]
};
